package fr.appliClient.server.mapping;

import org.dozer.Mapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import fr.appliClient.server.dto.VehicleDTO;
import fr.appliClient.server.entity.Vehicle;

@Component
public class VehicleMapping {

	@Autowired
	private Mapper mapper;

	/**
	 * Mapping vehicleDTO to Vehicle
	 * 
	 * @param dto
	 * @return
	 */
	public Vehicle vehicleDTOToVehicle(VehicleDTO dto) {

		Vehicle vehicle = this.mapper.map(dto, Vehicle.class);
		return vehicle;
	}

	/**
	 * Mapping vehicle to VehicleDTO
	 * 
	 * @param vehicle
	 * @return
	 */
	public VehicleDTO vehicleToVehicleDTO(Vehicle vehicle) {

		VehicleDTO dto = this.mapper.map(vehicle, VehicleDTO.class);
		return dto;
	}
}
